import Storage from "@/utils/storage";
import tools from "@/utils/tools"
export default {
    namespace: 'login',
    state: {
        status: undefined
    },
    effects: {
        *login({ payload, callback }, { call, put }) {
            if (payload) {
                let login_time = tools.getCurrentTime()
                payload.data = {
                    ...payload.data,
                    login_time
                }
                new Storage().set('user__info', payload, 60 * 24); // 分钟
            } else {
                new Storage().remove('user__info'); // 分钟
            }
            yield put({
                type: 'setPersons',
                payload
            })
        }
    },
    reducers: {
        setPersons(state, action) {
            return {
                ...state,
                persons: action.payload
            }
        }
    }
}